﻿#ifndef CALCULATOR2_H
#define CALCULATOR2_H

#include <QMainWindow>
#include <qstring.h>
#include <qchar.h>
#include <QStack>//栈
#include <QQueue>//队列数据结构

namespace Ui {
class calculator2;
}

class calculator2 : public QMainWindow
{
    Q_OBJECT

public:
    explicit calculator2(QWidget *parent = 0);
    ~calculator2();
    bool isOperator(QString s);
    QQueue<QString> split(QString& m_exp);
    int priority(QString s);
    bool math(QQueue<QString>& m_exp);
    bool isNumber(QString s);
    bool transform(QQueue<QString>& m_exp,QQueue<QString>& output);
    QString calculator(QString lp,QString op,QString rp);
    QString calculator(QQueue<QString>& m_exp);

    bool expression(QString& m_exp);
    QString result();


private slots:
    void on_pushButton_0_clicked();
    void on_pushButton_1_clicked();
    void on_pushButton_2_clicked();
    void on_pushButton_3_clicked();
    void on_pushButton_4_clicked();
    void on_pushButton_5_clicked();
    void on_pushButton_6_clicked();
    void on_pushButton_7_clicked();
    void on_pushButton_8_clicked();
    void on_pushButton_9_clicked();
    void on_pushButton_add_clicked();
    void on_pushButton_sub_clicked();
    void on_pushButton_mul_clicked();
    void on_pushButton_div_clicked();
    void on_pushButton_equal_clicked();
    void on_pushButton_clear_clicked();
    void on_pushButton_del_clicked();
    void on_pushButton_point_clicked();
    void on_pushButton_right_clicked();
    void on_pushButton_left_clicked();


private:
    Ui::calculator2 *ui;
    QString exp;
    QString m_result;
    QString m_exp;
};

#endif // CALCULATOR2_H
